home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 19
/
Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso
/
Aminet
/
comm
/
net
/
netmenu11.lha
/
Source
/
NetMenu.e
next >
Wrap
Text File
|
1997-03-16
|
20KB
|
734 lines
/*
**
** NetMenu v1.1 ®1996 Peter Gordon
**
** Just an example of how to make a little internet menu...
**
** Defaults set up for the following internet s/w:
**
** TCP/IP Stack: Miami
** Browser: IBrowse
** IRC Client: AmIRC
** FTP Client: Gui-FTP
**
** Requires:
** (to run) · Arexx to be running (Comes with WB)
** · WB2.0+ (Errr... Comes with yer Amiga :)
** (to compile) · EasyGUI 3.3+ (Aminet: dev/e/easygui*.lha)
** · EAudio (Aminet: dev/e/eaudio.lha)
** · Amiga E (Aminet: dev/e/amigae*.lha)
**
*/
OPT OSVERSION=37
MODULE 'tools/easygui', 'eaudio', 'libraries/gadtools',
'intuition/intuition', 'commodities', 'libraries/commodities',
'exec/ports', 'wb', 'workbench/workbench', 'icon'
OBJECT prefs
matchstr[4]:ARRAY OF CHAR, -> Filetype validation
playback_online, -> Playback rates for samples
playback_offline,
playback_irc,
playback_ftp,
playback_www,
playback_email,
load_tcp_stack[256]:ARRAY OF CHAR, -> String to execute when opening TCP/IP
tcp_stack_arexx[256]:ARRAY OF CHAR, -> Arexx prog to execute on open
shut_tcp_stack_arexx[256]:ARRAY OF CHAR, -> Arexx prog to execute on close
load_browser[256]:ARRAY OF CHAR, -> Etc. etc.
browser_arexx[256]:ARRAY OF CHAR,
shut_browser_arexx[256]:ARRAY OF CHAR,
load_irc[256]:ARRAY OF CHAR,
irc_arexx[256]:ARRAY OF CHAR,
shut_irc_arexx[256]:ARRAY OF CHAR,
load_ftp[256]:ARRAY OF CHAR,
ftp_arexx[256]:ARRAY OF CHAR,
shut_ftp_arexx[256]:ARRAY OF CHAR,
load_email[256]:ARRAY OF CHAR,
email_arexx[256]:ARRAY OF CHAR,
shut_email_arexx[256]:ARRAY OF CHAR,
online_arexx[256]:ARRAY OF CHAR,
offline_arexx[256]:ARRAY OF CHAR
x,y:INT
ENDOBJECT
DEF onlrx[256]:STRING, -> E-String for online rexx script name
oflrx[256]:STRING, -> E-String for offline rexx script name
loadtcp[256]:STRING, -> E-String for load TCP string
tcprx[256]:STRING, -> E-String for TCP rexx script name
qtcprx[256]:STRING, -> E-String for quit TCP rexx script name
loadwww[256]:STRING,
wwwrx[256]:STRING,
qwwwrx[256]:STRING,
loadirc[256]:STRING,
ircrx[256]:STRING,
qircrx[256]:STRING,
loadftp[256]:STRING,
ftprx[256]:STRING,
qftprx[256]:STRING,
loademail[256]:STRING,
emailrx[256]:STRING,
qemailrx[256]:STRING
DEF s_online, s_online_len, -> Online sample and length
s_offline, s_offline_len,
s_irc, s_irc_len,
s_ftp, s_ftp_len,
s_www, s_www_len,
s_email, s_email_len,
our_prefs:prefs, -> The prefs
lock,
gh:PTR TO guihandle, -> EasyGUI handle
cx_broker=NIL, -> Our commodities broker
cx_broker_mp=NIL:PTR TO mp, -> Broker message port
dobj:PTR TO diskobject, -> For our AppIcon
iconport:PTR TO mp,
appicon, appmsg:PTR TO appmessage
PROC main() HANDLE
DEF x,y,msg,msgid,msgtype,gmsg
-> Load the prefs
getPrefs()
-> Get any libs/resources/anything we need
getStuff()
-> Check if we're run from WB, and if so, lock PROGDIR: and current dir
-> it...
IF(wbmessage)
IF(lock:=Lock('PROGDIR:',-2)) ->ACCESS_READ
CurrentDir(lock)
ENDIF
ENDIF
-> Load the samples
s_online, s_online_len:=loadRaw('sounds/online.raw')
s_offline, s_offline_len:=loadRaw('sounds/offline.raw')
s_ftp, s_ftp_len:=loadRaw('sounds/ftp.raw')
s_irc, s_irc_len:=loadRaw('sounds/irc.raw')
s_www, s_www_len:=loadRaw('sounds/www.raw')
s_email, s_email_len:=loadRaw('sounds/email.raw')
-> Open a please wait window
gh:=guiinit('!Wait!',
[BEVEL,
[TEXT,'Setting up some stuff...',NIL,FALSE,40]
])
-> Open TCP/IP stack
run(our_prefs.load_tcp_stack)
Delay(50)
-> Run startup arexx script
rexxecute(our_prefs.tcp_stack_arexx)
-> Get rid of the wait window
cleangui(gh)
x:=our_prefs.x
y:=our_prefs.y
-> Open the main window
gh:=guiinit('NetMenu v1.1',
[BEVEL,
[EQROWS,
[COLS,
[BUTTON,{online},'Online'],
[SPACEH],
[BUTTON,{offline},'Offline'],
[SPACEH],
[BUTTON,{www},'WWW'],
[SPACEH],
[BUTTON,{irc},'IRC'],
[SPACEH],
[BUTTON,{ftp},'FTP'],
[SPACEH],
[BUTTON,{email},'E Mail']
],
[BAR],
[BUTTON,0,'Quit']
]
],0,0,0,
[NM_TITLE,0,'Project',0,0,0,0,
NM_ITEM,0,'Prefs','P',0,0,{prefs},
NM_ITEM,0,'Iconify','I',0,0,1,
NM_ITEM,0,'Quit','Q',0,0,0,
0,0,0,0,0,0,0]:newmenu,
0,x,y)
-> Wait till the window is closed
REPEAT
WaitTOF() -> Don't hog the system
IF(msg:=GetMsg(cx_broker_mp))
msgid:=CxMsgID(msg)
msgtype:=CxMsgType(msg)
ReplyMsg(msg)
IF(msgtype=CXM_COMMAND)
SELECT msgid
CASE CXCMD_DISABLE
ActivateCxObj(cx_broker, FALSE)
CASE CXCMD_ENABLE
ActivateCxObj(cx_broker, TRUE)
CASE CXCMD_DISAPPEAR
iconify()
CASE CXCMD_APPEAR
uniconify()
ENDSELECT
ENDIF
ENDIF
IF(gh) THEN gmsg:=guimessage(gh)
IF(gmsg=1)
iconify()
ENDIF
IF(dobj)
IF(appmsg:=GetMsg(iconport))
ReplyMsg(appmsg)
uniconify()
ENDIF
ENDIF
UNTIL (gmsg=0) OR (msgid=CXCMD_KILL) OR (msgid=CXCMD_UNIQUE)
-> Make sure we're uniconified
uniconify()
-> Close the window
cleangui(gh)
-> If browser is running, close it
rexxecute(our_prefs.shut_browser_arexx)
-> If FTP is running, close it
rexxecute(our_prefs.shut_ftp_arexx)
-> If IRC is running, close it
rexxecute(our_prefs.shut_ftp_arexx)
-> Quit TCP/IP stack
rexxecute(our_prefs.shut_tcp_stack_arexx)
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
-> Free up everything
freeStuff()
-> Unlock PROGDIR:
IF(lock)
UnLock(lock)
ENDIF
EXCEPT
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
WriteF('Fatal Error!\n')
ENDPROC
PROC online()
-> Go online
rexxecute(our_prefs.online_arexx)
IF(s_online)
playData(s_online,s_online_len,our_prefs.playback_online,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC offline()
-> Go offline
rexxecute(our_prefs.offline_arexx)
IF(s_offline)
playData(s_offline,s_offline_len,our_prefs.playback_offline,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC www()
-> Run IBrowse
run(our_prefs.load_browser)
IF(StrLen(our_prefs.browser_arexx)>0)
Delay(100) -> Wait 2 secs
rexxecute(our_prefs.browser_arexx)
ENDIF
IF(s_www)
playData(s_www,s_www_len,our_prefs.playback_www,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC irc()
-> Run AmIRC
run(our_prefs.load_irc)
IF(StrLen(our_prefs.irc_arexx)>0)
Delay(100) -> Wait 2 secs
rexxecute(our_prefs.irc_arexx)
ENDIF
IF(s_irc)
playData(s_irc,s_irc_len,our_prefs.playback_irc,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC ftp()
-> Run GUI-FTP
run(our_prefs.load_ftp)
IF(StrLen(our_prefs.ftp_arexx)>0)
Delay(100) -> Wait 2 secs
rexxecute(our_prefs.ftp_arexx)
ENDIF
IF(s_ftp)
playData(s_ftp,s_ftp_len,our_prefs.playback_ftp,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC email()
-> Run E-Mail
run(our_prefs.load_email)
IF(StrLen(our_prefs.email_arexx)>0)
Delay(100) -> Wait 2 secs
rexxecute(our_prefs.email_arexx)
ENDIF
IF(s_email)
playData(s_email,s_email_len,our_prefs.playback_email,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
-> Run an arexx script
PROC rexxecute(str)
DEF mstr[256]:STRING,h
IF(lock)
CurrentDir(lock)
ENDIF
IF(h:=Open('NIL:',NEWFILE))
-> Normally I wouldn't specify "sys:rexxc/" but i cant get it to
-> work from the workbench icon without it (?)
StringF(mstr,'sys:rexxc/rx >NIL: \s',str)
Execute(mstr,0,h)
Close(h)
ENDIF
ENDPROC
-> Run a program
PROC run(name)
StringF(onlrx,'Run >NIL: \s',name)
Execute(onlrx,0,0)
ENDPROC
PROC getPrefs()
DEF h, gp, size
gp:=0
our_prefs.x:=-1
our_prefs.y:=-1
-> Check the file length
size:=FileLength('s:NetMenu.prefs')
IF(size=SIZEOF prefs) OR (size=SIZEOF prefs-4)
IF(h:=Open('s:NetMenu.prefs',OLDFILE))
Read(h,our_prefs,size)
Close(h)
IF(StrCmp(our_prefs.matchstr,'NMP',4)) THEN gp:=1
ENDIF
ENDIF
-> If we couldn't load the prefs properly, make a new prefs file
-> With all the defaults
IF(gp=0)
doCopy(our_prefs.matchstr,'NMP')
our_prefs.playback_online:=13964
our_prefs.playback_offline:=13964
our_prefs.playback_www:=8404
our_prefs.playback_irc:=8404
our_prefs.playback_ftp:=16384
our_prefs.playback_email:=8404
doCopy(our_prefs.load_tcp_stack,'Miami')
doCopy(our_prefs.tcp_stack_arexx,'rexx/hide_miami.rexx')
doCopy(our_prefs.shut_tcp_stack_arexx,'rexx/quit_miami.rexx')
doCopy(our_prefs.load_browser,'IBrowse')
doCopy(our_prefs.browser_arexx,'')
doCopy(our_prefs.shut_browser_arexx,'rexx/quit_browser.rexx')
doCopy(our_prefs.load_irc,'AmIRC')
doCopy(our_prefs.irc_arexx,'')
doCopy(our_prefs.shut_irc_arexx,'rexx/Close_irc.rexx')
doCopy(our_prefs.load_ftp,'GUI-FTP')
doCopy(our_prefs.ftp_arexx,'')
doCopy(our_prefs.shut_ftp_arexx,'rexx/Close_ftp.rexx')
doCopy(our_prefs.online_arexx,'rexx/Online.rexx')
doCopy(our_prefs.offline_arexx,'rexx/Offline.rexx')
savePrefs()
ENDIF
ENDPROC
PROC savePrefs()
DEF h
IF(h:=Open('s:NetMenu.prefs',NEWFILE))
our_prefs.x:=gh.wnd.leftedge
our_prefs.y:=gh.wnd.topedge
Write(h,our_prefs,SIZEOF prefs)
Close(h)
ENDIF
ENDPROC
PROC doCopy(da,s)
DEF cnt
FOR cnt:=0 TO StrLen(s)
PutChar(da+cnt,Char(s+cnt))
ENDFOR
ENDPROC
PROC prefs()
-> Copy all strings to E-Strings for EasyGUI
StrCopy(onlrx,our_prefs.online_arexx)
StrCopy(oflrx,our_prefs.offline_arexx)
StrCopy(loadtcp,our_prefs.load_tcp_stack)
StrCopy(tcprx,our_prefs.tcp_stack_arexx)
StrCopy(qtcprx,our_prefs.shut_tcp_stack_arexx)
StrCopy(loadwww,our_prefs.load_browser)
StrCopy(wwwrx,our_prefs.browser_arexx)
StrCopy(qwwwrx,our_prefs.shut_browser_arexx)
StrCopy(loadirc,our_prefs.load_irc)
StrCopy(ircrx,our_prefs.irc_arexx)
StrCopy(qircrx,our_prefs.shut_irc_arexx)
StrCopy(loadftp,our_prefs.load_ftp)
StrCopy(ftprx,our_prefs.ftp_arexx)
StrCopy(qftprx,our_prefs.shut_ftp_arexx)
StrCopy(loademail,our_prefs.load_email)
StrCopy(emailrx,our_prefs.email_arexx)
StrCopy(qemailrx,our_prefs.shut_email_arexx)
-> Opent the prefs window
easygui('NetMenu Prefs',
[BEVEL,
[EQROWS,
[BUTTON,{prf_tcp},'TCP prefs'],
[BUTTON,{prf_www},'WWW prefs'],
[BUTTON,{prf_irc},'IRC prefs'],
[BUTTON,{prf_ftp},'FTP prefs'],
[BUTTON,{prf_email},'Email Prefs'],
[BUTTON,{prf_dia},'Dial prefs'],
[BUTTON,{prf_sound},'Sound prefs'],
[BAR],
[COLS,
[BUTTON,0,'Close'],
[SPACEH],
[BUTTON,{savePrefs},'Save Prefs']
]
]
])
ENDPROC
PROC prf_tcp()
easygui('NetMenu Prefs -TCP',
[BEVEL,
[EQROWS,
[STR,{dummy},'_Load TCP:',loadtcp,255,20,0,0,Char('l')],
[STR,{dummy},'_TCP Arexx:',tcprx,255,20,0,0,Char('t')],
[STR,{dummy},'_Shut TCP:',qtcprx,255,20,0,0,Char('s')],
[BAR],
[BUTTON,0,'Close']
]
])
-> Put the changed strings back into the prefs structure
doCopy(our_prefs.load_tcp_stack,loadtcp)
doCopy(our_prefs.tcp_stack_arexx,tcprx)
doCopy(our_prefs.shut_tcp_stack_arexx,qtcprx)
ENDPROC
PROC prf_email()
easygui('NetMenu Prefs -EMail',
[BEVEL,
[EQROWS,
[STR,{dummy},'_Load EMail:',loademail,255,20,0,0,Char('l')],
[STR,{dummy},'_EMail Arexx:',emailrx,255,20,0,0,Char('e')],
[STR,{dummy},'_Shut EMail:',qemailrx,255,20,0,0,Char('s')],
[BAR],
[BUTTON,0,'Close']
]
])
-> Put the changed strings back into the prefs structure
doCopy(our_prefs.load_email,loademail)
doCopy(our_prefs.email_arexx,emailrx)
doCopy(our_prefs.shut_email_arexx,qemailrx)
ENDPROC
PROC prf_www()
easygui('NetMenu Prefs -WWW',
[BEVEL,
[EQROWS,
[STR,{dummy},'_Load WWW:',loadwww,255,20,0,0,Char('l')],
[STR,{dummy},'_WWW Arexx:',wwwrx,255,20,0,0,Char('w')],
[STR,{dummy},'_Shut WWW:',qwwwrx,255,20,0,0,Char('s')],
[BAR],
[BUTTON,0,'Close']
]
])
doCopy(our_prefs.load_browser,loadwww)
doCopy(our_prefs.browser_arexx,wwwrx)
doCopy(our_prefs.shut_browser_arexx,qwwwrx)
ENDPROC
PROC prf_irc()
easygui('NetMenu Prefs -IRC',
[BEVEL,
[EQROWS,
[STR,{dummy},'_Load IRC:',loadirc,255,20,0,0,Char('l')],
[STR,{dummy},'_IRC Arexx:',ircrx,255,20,0,0,Char('i')],
[STR,{dummy},'_Shut IRC:',qircrx,255,20,0,0,Char('s')],
[BAR],
[BUTTON,0,'Close']
]
])
doCopy(our_prefs.load_irc,loadirc)
doCopy(our_prefs.irc_arexx,ircrx)
doCopy(our_prefs.shut_irc_arexx,qircrx)
ENDPROC
PROC prf_ftp()
easygui('NetMenu Prefs -FTP',
[BEVEL,
[EQROWS,
[STR,{dummy},'_Load FTP:',loadftp,255,20,0,0,Char('l')],
[STR,{dummy},'_FTP Arexx:',ftprx,255,20,0,0,Char('f')],
[STR,{dummy},'_Shut FTP:',qftprx,255,20,0,0,Char('s')],
[BAR],
[BUTTON,0,'Close']
]
])
doCopy(our_prefs.load_ftp,loadftp)
doCopy(our_prefs.ftp_arexx,ftprx)
doCopy(our_prefs.shut_ftp_arexx,qftprx)
ENDPROC
PROC prf_dia()
easygui('NetMenu Prefs -Dial',
[BEVEL,
[EQROWS,
[STR,{dummy},'_Online Arexx:',onlrx,255,20,0,0,Char('o')],
[STR,{dummy},'O_ffline Arexx:',oflrx,255,20,0,0,Char('f')],
[BAR],
[BUTTON,0,'Close']
]
])
doCopy(our_prefs.online_arexx,onlrx)
doCopy(our_prefs.offline_arexx,oflrx)
ENDPROC
PROC prf_sound()
easygui('NetMenu Prefs -Sound',
[BEVEL,
[EQROWS,
[COLS,
[SLIDE,{sound1},'Online.RAW playrate: ',0,8404,32767,our_prefs.playback_online,30,'%6ld',0,0,(s_online=0)],
[BUTTON,{stest1},'Test',0,0,0,(s_online=0)]
],
[COLS,
[SLIDE,{sound2},'Offline.RAW playrate: ',0,8404,32767,our_prefs.playback_offline,30,'%6ld',0,0,(s_offline=0)],
[BUTTON,{stest2},'Test',0,0,0,(s_offline=0)]
],
[COLS,
[SLIDE,{sound3},'WWW.RAW playrate: ',0,8404,32767,our_prefs.playback_www,30,'%6ld',0,0,(s_www=0)],
[BUTTON,{stest3},'Test',0,0,0,(s_www=0)]
],
[COLS,
[SLIDE,{sound4},'IRC.RAW playrate: ',0,8404,32767,our_prefs.playback_irc,30,'%6ld',0,0,(s_irc=0)],
[BUTTON,{stest4},'Test',0,0,0,(s_irc=0)]
],
[COLS,
[SLIDE,{sound5},'FTP.RAW playrate: ',0,8404,32767,our_prefs.playback_ftp,30,'%6ld',0,0,(s_ftp=0)],
[BUTTON,{stest5},'Test',0,0,0,(s_ftp=0)]
],
[COLS,
[SLIDE,{sound6},'EMAIL.RAW playrate: ',0,8404,32767,our_prefs.playback_email,30,'%6ld',0,0,(s_email=0)],
[BUTTON,{stest6},'Test',0,0,0,(s_email=0)]
],
[BAR],
[BUTTON,0,'Close']
]
])
ENDPROC
PROC sound1(null,val)
our_prefs.playback_online:=val
ENDPROC
PROC stest1()
IF(s_online)
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
WaitTOF()
playData(s_online,s_online_len,our_prefs.playback_online,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC sound2(null,val)
our_prefs.playback_offline:=val
ENDPROC
PROC stest2()
IF(s_offline)
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
WaitTOF()
playData(s_offline,s_offline_len,our_prefs.playback_offline,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC sound3(null,val)
our_prefs.playback_www:=val
ENDPROC
PROC stest3()
IF(s_online)
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
WaitTOF()
playData(s_www,s_www_len,our_prefs.playback_www,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC sound4(null,val)
our_prefs.playback_irc:=val
ENDPROC
PROC stest4()
IF(s_irc)
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
WaitTOF()
playData(s_irc,s_irc_len,our_prefs.playback_irc,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC sound5(null,val)
our_prefs.playback_ftp:=val
ENDPROC
PROC stest5()
IF(s_ftp)
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
WaitTOF()
playData(s_ftp,s_ftp_len,our_prefs.playback_ftp,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
PROC sound6(null,val)
our_prefs.playback_email:=val
ENDPROC
PROC stest6()
IF(s_email)
stopChannels(CHAN_LEFT1+CHAN_RIGHT1)
WaitTOF()
playData(s_email,s_email_len,our_prefs.playback_email,CHAN_LEFT1+CHAN_RIGHT1,64)
WaitTOF()
exitLoop(CHAN_LEFT1+CHAN_RIGHT1)
ENDIF
ENDPROC
-> Used when you dont want an action for a button, but you also dont
-> want that button to close the gui
PROC dummy()
ENDPROC
-> Anything we need to open
PROC getStuff()
cxbase:=OpenLibrary('commodities.library',37)
iconbase:=OpenLibrary('icon.library',37)
workbenchbase:=OpenLibrary('workbench.library',37)
-> Setup all the commodities crap
IF(cxbase)
IF(cx_broker_mp:=CreateMsgPort())
cx_broker:=CxBroker([NB_VERSION, 0,
'NetMenu',
'NetMenu v1.1',
'Internet App Launcher by P. Gordon',
NBU_UNIQUE OR NBU_NOTIFY,
TRUE,0,0,cx_broker_mp,0]:newbroker,NIL)
ActivateCxObj(cx_broker,TRUE)
ENDIF
ENDIF
ENDPROC
PROC freeStuff()
DEF msg
IF(cx_broker) THEN DeleteCxObjAll(cx_broker)
IF(cx_broker_mp)
WHILE msg:=GetMsg(cx_broker_mp) DO ReplyMsg(msg)
DeleteMsgPort(cx_broker_mp)
ENDIF
IF(cxbase) THEN CloseLibrary(cxbase)
IF(iconbase) THEN CloseLibrary(iconbase)
IF(workbenchbase) THEN CloseLibrary(workbenchbase)
ENDPROC
PROC iconify()
IF(dobj) THEN RETURN -> We are already iconified, so return
-> Initialise our icon
dobj:=GetDefDiskObject(WBTOOL)
dobj.type:=NIL
-> Get a message port
IF(iconport:=CreateMsgPort())
-> Add the app icon to workbench
appicon:=AddAppIconA(0,0,'NetMenu',iconport,NIL,dobj,NIL)
ELSE
FreeDiskObject(dobj)
dobj:=0
RETURN
ENDIF
-> If the gui is open, close it
IF(gh) THEN cleangui(gh)
gh:=0
ENDPROC
PROC uniconify()
IF(dobj=0) THEN RETURN -> We are already uniconified
-> Remove the icon
IF(appicon) THEN RemoveAppIcon(appicon)
-> Remove the port
IF(iconport)
-> Clear away any messages that arrived at the last moment
WHILE appmsg:=GetMsg(iconport) DO ReplyMsg(appmsg)
DeleteMsgPort(iconport)
ENDIF
FreeDiskObject(dobj)
dobj:=0
-> Open the main window
gh:=guiinit('NetMenu v1.1',
[BEVEL,
[EQROWS,
[COLS,
[BUTTON,{online},'Online'],
[SPACEH],
[BUTTON,{offline},'Offline'],
[SPACEH],
[BUTTON,{www},'WWW'],
[SPACEH],
[BUTTON,{irc},'IRC'],
[SPACEH],
[BUTTON,{ftp},'FTP'],
[SPACEH],
[BUTTON,{email},'E Mail']
],
[BAR],
[BUTTON,0,'Quit']
]
],0,0,0,
[NM_TITLE,0,'Project',0,0,0,0,
NM_ITEM,0,'Prefs','P',0,0,{prefs},
NM_ITEM,0,'Iconify','I',0,0,1,
NM_ITEM,0,'Quit','Q',0,0,0,
0,0,0,0,0,0,0]:newmenu,
0,our_prefs.x,our_prefs.y)
ENDPROC